package com.zsc.oj.model.vo;

import cn.hutool.json.JSONUtil;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.zsc.oj.model.entity.TbComment;
import com.zsc.oj.model.entity.User;
import lombok.Data;
import org.springframework.beans.BeanUtils;

import java.io.Serializable;
import java.util.Date;
import java.util.List;

/**
 * 评论视图
 *
 * @author <a href="https://github.com/liyupi">程序员鱼皮</a>
 * @from <a href="https://www.code-nav.cn">编程导航学习圈</a>
 */
@Data
public class TbCommentVO implements Serializable {

    /**
     * id
     */
    private Long id;

    /**
     * 内容
     */
    private String content;

    /**
     * 点赞数
     */
    private Integer thumbNum;

    /**
     * 创建用户 id
     */
    private Long userId;

    /**
     * 回复那个人的id
     */
    private Long replyId;

    /**
     * 创建时间
     */
    private Date createTime;

    /**
     * 创建人信息
     */
    private UserVO user;

    /**
     * 封装类转对象
     *
     * @param tbCommentVO
     * @return
     */
    public static TbComment voToObj(TbCommentVO tbCommentVO) {
        if (tbCommentVO == null) {
            return null;
        }
        TbComment tbComment = new TbComment();
        BeanUtils.copyProperties(tbCommentVO, tbComment);
        return tbComment;
    }

    /**
     * 对象转封装类
     *
     * @param tbComment
     * @return
     */
    public static TbCommentVO objToVo(TbComment tbComment) {
        if (tbComment == null) {
            return null;
        }
        TbCommentVO tbCommentVO = new TbCommentVO();
        BeanUtils.copyProperties(tbComment, tbCommentVO);
        return tbCommentVO;
    }
}
